<template>
  <div id="app">
    <Header :title="title" :bgcolor="bgcolor"></Header>
    <!-- <List></List> -->
    <!-- 中间是动态显示的页面 -->
    <keep-alive>
      <components :is="comName"></components>
    </keep-alive>
    <Menu :menuList="menuList" @changeComponent="changeCom"></Menu>
  </div>
</template>

<script>
import Header from "@/views/header.vue";
import List from "./views/list.vue";
import Menu from "./views/menu.vue";
import Search from "./views/search.vue";
import My from "./views/my.vue";

export default {
  name: "App",
  components: {
    Header,
    List,
    Menu,
    Search,
    My,
  },
  methods: {
    changeCom(index) {
      this.comName = this.menuList[index].comName;
    },
  },
  data() {
    return {
      comName: "List",
      bgcolor: "pink",
      title: "TabBar案例",
      menuList: [
        {
          icon: "icon-shangpinliebiao",
          text: "商品列表",
          comName: "List",
        },
        {
          icon: "icon-sousuo",
          text: "商品搜索",
          comName: "Search",
        },
        {
          icon: "icon-user",
          text: "我的信息",
          comName: "My",
        },
      ],
    };
  },
};
</script>

<style>
#app {
  padding: 50px 0;
}
</style>
